package thread;

import java.util.Scanner;

public class SleepDemo {
    public static void main(String[] args) {
        /*long startTime = System.currentTimeMillis();
        System.out.println("程序开始了");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("程序结束了");
        long endTime = System.currentTimeMillis();
        System.out.println("程序运行了" + (endTime - startTime) + "毫秒");*/

        System.out.println("程序开始了");
        System.out.println("请输入倒计时的秒数：");
        Scanner scan = new Scanner(System.in);
        long startTime = System.currentTimeMillis();
        for (int i = scan.nextInt(); i > 0; i--){
            System.out.println(i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        long endTime = System.currentTimeMillis();
        System.out.println("时间到");
        System.out.println("倒计时结束");
        System.out.println("程序运行了" + (endTime - startTime) + "毫秒");
    }
}
